import { _decorator, Component, Node, AnimationClip, Vec3 } from 'cc';
import { LoadAnimation } from './LoadAnimation';
const { ccclass, property } = _decorator;

@ccclass('scene1')
export class scene1 extends Component {

    @property(Node)
    public animationContainer: Node|null = null;

    start() {
        // get singleton
        const loadAnimationInstance = LoadAnimation.getInstance();

        const background = loadAnimationInstance.newNode('back', new Vec3(0, 0, 0), 0, 9, 'loading', 'textures/animation/background', AnimationClip.WrapMode.Normal);
        this.animationContainer?.addChild(background);

        const monster_mid = loadAnimationInstance.newNode('monster_m', new Vec3(0, 0, 0), 0, 31, 'waiting', 'textures/animation/monster', AnimationClip.WrapMode.Loop);
        this.animationContainer?.addChild(monster_mid);

        const monster_south = loadAnimationInstance.newNode('monster_s', new Vec3(0, -240, 0), 0, 5, 'moving', 'textures/animation/monster_move', AnimationClip.WrapMode.PingPong);
        this.animationContainer?.addChild(monster_south);

        const monster_south_west = loadAnimationInstance.newNode('monster_se', new Vec3(-440, -240, 0), 6, 11, 'moving', 'textures/animation/monster_move', AnimationClip.WrapMode.PingPong);
        this.animationContainer?.addChild(monster_south_west);

        const monster_west = loadAnimationInstance.newNode('monster_w', new Vec3(-440, 0, 0), 12, 17, 'moving', 'textures/animation/monster_move', AnimationClip.WrapMode.PingPong);
        this.animationContainer?.addChild(monster_west);

        const monster_north_west = loadAnimationInstance.newNode('monster_nw', new Vec3(-440, 240, 0), 18, 23, 'moving', 'textures/animation/monster_move', AnimationClip.WrapMode.PingPong);
        this.animationContainer?.addChild(monster_north_west);

        const monster_north = loadAnimationInstance.newNode('monster_n', new Vec3(0, 240, 0), 24, 29, 'moving', 'textures/animation/monster_move', AnimationClip.WrapMode.PingPong);
        this.animationContainer?.addChild(monster_north);

        const monster_north_east = loadAnimationInstance.newNode('monster_ne', new Vec3(440, 240, 0), 30, 35, 'moving', 'textures/animation/monster_move', AnimationClip.WrapMode.PingPong);
        this.animationContainer?.addChild(monster_north_east);

        const monster_east = loadAnimationInstance.newNode('monster_e', new Vec3(440, 0, 0), 36, 41, 'moving', 'textures/animation/monster_move', AnimationClip.WrapMode.PingPong);
        this.animationContainer?.addChild(monster_east);

        const monster_south_east = loadAnimationInstance.newNode('monster_se', new Vec3(440, -240, 0), 42, 47, 'moving', 'textures/animation/monster_move', AnimationClip.WrapMode.PingPong);
        this.animationContainer?.addChild(monster_south_east);
    }

    update(deltaTime: number) {
        
    }
}


